/**
 * @version Create on 2012-11-13
 * @author Yinzi Chen
 */

public class SqrtX {

	public int sqrt(int x) {
		if (x == 0)
			return 0;
		int l = 1, r = 1 << 16, mid;
		while (l <= r) {
			mid = l + r >> 1;
			if (mid > x / mid) {
				r = mid - 1;
			} else {
				l = mid + 1;
			}
		}
		return r;
	}

	public static void main(String[] args) {

	}

}
